package com.yaosheng.thread.jvm;

/**
 * Created by yaosheng on 2021/7/15.
 * -XX:-DoEscapeAnalysis -XX:-EliminateAllocations -XX:-UseTLAB
 * 逃逸分析 标量替换 线程专有对象分配
 */
public class TestTLAB {

    class User {

        int d;
        String name;

        public User(int d,String name){
            d = this.d;
            name = this.name;
        }
    }

    void alloc(int i){
        new User (i,"name" + i);
    }

    public static void main(String[] args) {

        TestTLAB tlab = new TestTLAB ();
        long start = System.currentTimeMillis ();
        for(int i = 0;i < 1000_0000;i ++){
            tlab.alloc(i);
        }
        long end = System.currentTimeMillis ();
        System.out.println (end - start);
    }
}
